<?php
defined('BASEPATH') or exit('No direct script access allowed');

class person_data_service
{
    private $CI;
    public function __construct()
    {
        $this->CI = &get_instance();
        $this->CI->load->model("Academia_job_model");
        $this->CI->load->model("Academic_report_model");
        $this->CI->load->model("Audit_model");
        $this->CI->load->model("Awards_model");
        $this->CI->load->model("Communication_model");
        $this->CI->load->model("Horizontal_project_model");
        $this->CI->load->model("Monograph_model");
        $this->CI->load->model("Paper_model");
        $this->CI->load->model("Patent_data_model");
        $this->CI->load->model("Patent_model");
        $this->CI->load->model("Research_report_model");
        $this->CI->load->model("Science_conversion_model");
        $this->CI->load->model("Technical_standard_model");
        $this->CI->load->model("Vertical_project_model");
        $this->CI->load->model("Subject_platform_model");
        $this->CI->load->model("User_model");
        $this->CI->load->library('PHPExcel/PHPExcel');        
		$this->CI->load->model("Admin_model");
    }


    //论文模块
    public function paper($param, $is_export,$check){
             if($is_export){
                $connar['items'] = "db_paper.id,db_paper.publish_time,db_paper.name,db_paper.journal_name,db_paper.journal_level,db_paper.subject,db_paper.school_rank,db_paper.personal_rank,author.identity,author.author,db_paper.volume_number,db_paper.issue_number,db_paper.page_range,db_paper.words_number,db_paper.cn,db_paper.issn,db_paper.journal_type,db_paper.journal_range,db_paper.is_cooperation,db_paper.type,db_paper.dept_name,db_paper.performance_score,db_paper.bonus,db_paper.award_year,db_paper.only_code";
                }else{
                    $connar['items'] = "db_paper.id,db_paper.publish_time,db_paper.name,db_paper.journal_name,db_paper.journal_level,db_paper.subject,db_paper.school_rank,db_paper.personal_rank,author.identity,author.author,db_paper.type,db_paper.award_year,db_paper.only_code";
                }
                
                $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
                $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::First[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_paper.id');
                // if (isset($param['name'])) {
                //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
                // }
                if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::First[XPHEnum::Value].') author1','author1.data_id=db_paper.id');
                    $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
                if (isset($param['year']) && $param['year'] != '') {
                    $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_paper.publish_time), "%Y" ) =?? ', array($param['year']));
                }    
                if (isset($param['submit_year']) && $param['submit_year'] != '') {
                    $connar['where'] .= $this->CI->sqlEscape(' and db_paper.award_year=?? ', array($param['submit_year']));
                }            
                if($is_export){
                    if(isset($check)){
                        if(in_array(ResultsType::First[XPHEnum::Value], $check)){
                            $id_data=$param['check'][ResultsType::First[XPHEnum::Value]];
                            $id = '';
                            foreach ($id_data as $k => $v) {
                                if($k==0){
                                    $id="'".$v."'";
                                }else{
                                    $id.=",'".$v."'";
                                }
                            }
                            $connar['where'] .=" and db_paper.id in(".$id.")";
                        }else{
                            $connar['where'].=" and 1<>1";
                        }
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }        
                $data = $this->CI->Paper_model->get_list_full($connar);
                foreach ($data as $k => $v) {
                 if(isset($v['is_cooperation'])){
                        $data[$k]['is_cooperation'] = (new CommonWhether())->show($v['is_cooperation']);
                    } 
                    $data[$k]['publish_time'] = $v['publish_time'] ? date('Y-m-d', $v['publish_time']) : '--';
                     if(isset($v['award_year'])){
                        $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                    }else{
                         $data[$k]['award_year'] = '';
                    }
                    // 判断是否外校                
                    $author=array_unique(explode(',', $v['author']));
                    $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                    $own_author=array_search($param['name'], explode(',', $v['author']));
                    // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                      $name_arr = explode(",",$param['name']);
                      $name = $name_arr[0];
                      if($name !=$author[$own_identity]){
                            $data[$k]['school_rank']='成员';
                            $data[$k]['personal_rank']='成员';
                        }
                 
                    unset($data[$k]['identity']);               
                }

                if($is_export){
                    $table_col = array('选择','序号', '发表时间', '论文题目', '刊物名称', '刊物级别', '学科门类', '本校排名','个人排名', '作者','卷号','期号','页码范围','字数(千字)','CN','ISSN','刊物发行类型','刊物发表范围','是否合作完成','论文类型','所属单位','业绩分','奖金','业绩（成果）归属年份','业绩编码');
                }else{
                    $table_col = array('选择','序号', '发表时间', '论文题目', '刊物名称', '刊物级别', '学科门类', '本校排名', '个人排名','作者','论文类型','业绩（成果）归属年份','业绩编码');
                }
       
                $type_name         = ResultsType::First[XPHEnum::Caption];

                return array('table_name'=>$type_name,'table_col'=> $table_col,'data'=>$data);         
    }


    //专著模块
    public function  monograph($param, $is_export,$check){
         if($is_export){
            $connar['items'] = "db_monograph.id,db_monograph.publish_time,db_monograph.name,db_monograph.publish_house,db_monograph.publish_house_level,db_monograph.subject,db_monograph.school_rank,db_monograph.personal_rank,author.identity,author.author,db_monograph.words_number,db_monograph.school_words_number,db_monograph.type,db_monograph.nature,db_monograph.publish_address,db_monograph.isbn,db_monograph.is_cooperation,db_monograph.dept_name,db_monograph.performance_score,db_monograph.bonus,db_monograph.remark,db_monograph.award_year,db_monograph.only_code";
         }else{
            $connar['items'] = "db_monograph.id,db_monograph.publish_time,db_monograph.name,db_monograph.publish_house,db_monograph.publish_house_level,db_monograph.subject,db_monograph.school_rank,db_monograph.personal_rank,author.identity,author.author,db_monograph.award_year,db_monograph.only_code";
         }
            
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Second[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_monograph.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                   $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Second[XPHEnum::Value].') author1','author1.data_id=db_monograph.id');
                   $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_monograph.publish_time), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and db_monograph.award_year=?? ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Second[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Second[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_monograph.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Monograph_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                if(isset($v['is_cooperation'])){
                    $data[$k]['is_cooperation'] = (new CommonWhether())->show($v['is_cooperation']);
                } 
                $data[$k]['publish_time'] = date('Y-m-d', $v['publish_time']);
                   if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                 $name_arr = explode(",",$param['name']);
                      $name = $name_arr[0];
                      if($name !=$author[$own_identity]){
                            $data[$k]['school_rank']='成员';
                            $data[$k]['personal_rank']='成员';
                        }
                unset($data[$k]['identity']);                
            }
            if($is_export){
                 $table_col         = array('选择','序号', '出版时间', '专著名称', '出版社名称', '出版社级别', '学科门类', '本校排名', '个人排名','作者','总字数(千字)','本校撰写字数（千字）','著作类别','资助等级','出版地','ISBN号','是否合作完成','所属单位','业绩分','奖金','备注','业绩（成果）归属年份','业绩编码');
             }else{
                 $table_col         = array('选择','序号', '出版时间', '专著名称', '出版社名称', '出版社级别', '学科门类', '本校排名', '个人排名','作者','业绩（成果）归属年份','业绩编码');
             }
           
            $type_name         = ResultsType::Second[XPHEnum::Caption];
            return array('table_name'=>$type_name,'table_col'=> $table_col,'data'=>$data);    

    }

    //专利模块
    public function patent($param, $is_export,$check){

            if($is_export){
                   $connar['items'] = "db_patent.id,db_patent.announcement_date,db_patent.name,db_patent.type,db_patent.patent_number,db_patent.school_rank,db_patent.personal_rank,author.author,author.identity,db_patent.apply_date,db_patent.owner,db_patent.range,db_patent.state,db_patent.agent,db_patent.agent_dept,db_patent.is_exclusive,db_patent.dept_name,db_patent.performance_score,db_patent.bonus,db_patent.remark,db_patent.award_year,db_patent.only_code";
             }else{
                   $connar['items'] = "db_patent.id,db_patent.announcement_date,db_patent.name,db_patent.type,db_patent.patent_number,db_patent.school_rank,db_patent.personal_rank,author.author,author.identity,db_patent.award_year,db_patent.only_code";
                //  $connar['items'] = "id,announcement_date,name,type,patent_number,school_rank,personal_rank,author.author,author.identity,award_year";
             }
         
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Third[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_patent.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Third[XPHEnum::Value].') author1','author1.data_id=db_patent.id');
                   $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_patent.announcement_date), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and db_patent.award_year=?? ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Third[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Third[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_patent.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Patent_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['announcement_date'] = date('Y-m-d', $v['announcement_date']);
                if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                if($is_export){
                 $data[$k]['apply_date'] = date('Y-m-d', $v['apply_date']);
                 $data[$k]['is_exclusive'] = (new CommonWhether())->show($v['is_exclusive']);
                 $data[$k]['state'] = (new PatentSystemState())->show($v['state']);
                }

                $identity_title=array_unique(explode(',', $v['identity']));      
                $author=array_unique(explode(',', $v['author']));  
                if(isset($param['name']) && $param['name']!=-1){
                    // 判断是否外校
                    $author=array_unique(explode(',', $v['author']));
                    $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                    $own_author=array_search($param['name'], explode(',', $v['author']));
                    // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    if($name!=$author[0]){
                        $data[$k]['school_rank']='成员';
                        $data[$k]['personal_rank']='成员';
                    }
                }           
            }

            foreach ($data as $k2 => $v) {
              $identity_title=array_unique(explode(',', $v['identity']));   
              if(count($identity_title)==1){
                 $data[$k2]['identity'] = (new CommonIdentity)->show($identity_title[0]);
               }else{
                     $identity_title_arr = array();
                     foreach ($identity_title as $k1 => $v) {
                        $identity_title_arr[$k1]=(new CommonIdentity)->show($v);
                    }
                    $data[$k2]['identity'] =implode('/', $identity_title_arr);
               }
           }

            if($is_export){
                 $table_col  = array('选择','序号', '授权时间', '专利名称', '专利类型', '专利号', '本校排名', '个人排名','发明人','本校教师/学生','申请日','专利权人','专利范围','专利状态','代理人','代理单位','专利权是否独享','所属单位','业绩分','奖金','备注','业绩（成果）归属年份','业绩编码');
             }else{
                 $table_col  = array('选择','序号', '授权时间', '专利名称', '专利类型', '专利号', '本校排名', '个人排名','发明人', '本校教师/学生','业绩（成果）归属年份','业绩编码');
             }
                    
            $type_name         = ResultsType::Third[XPHEnum::Caption];
            return array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }


        //获奖模块
    public function awards($param, $is_export,$check){
         if($is_export){
                 $connar['items'] = "db_awards.id,db_awards.award_time,db_awards.name,db_awards.award_name,db_awards.award_dept,db_awards.award_type,db_awards.award_grade,db_awards.school_rank,db_awards.personal_rank,author.identity,author.author,db_awards.subject,db_awards.award_year,db_awards.award_session,db_awards.award_level,db_awards.is_cooperation,db_awards.certificate_number,db_awards.dept_name,db_awards.performance_score,db_awards.remark,db_awards.only_code";
             }else{
                 $connar['items'] = "db_awards.id,db_awards.award_time,db_awards.name,db_awards.award_name,db_awards.award_dept,db_awards.award_level,db_awards.award_type,db_awards.award_grade,db_awards.school_rank,db_awards.personal_rank,author.identity,author.author,db_awards.award_year,db_awards.only_code";
             }
           
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Fourth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_awards.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }

              if (isset($param['name']) && $param['name']!=-1) {
                   $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Fourth[XPHEnum::Value].') author1','author1.data_id=db_awards.id');
                     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_awards.award_time), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and db_awards.award_year=?? ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Fourth[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Fourth[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_awards.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Awards_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['award_time'] = date('Y-m-d', $v['award_time']);
                if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                 if($is_export){
                 $data[$k]['is_cooperation'] = (new CommonWhether())->show($v['is_cooperation']);
                }
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                $name_arr = explode(",",$param['name']);
                 $name = $name_arr[0];
                  if($name !=$author[$own_identity]){
                        $data[$k]['school_rank']='成员';
                        $data[$k]['personal_rank']='成员';
                    } 
                unset($data[$k]['identity']);           
            }

            if($is_export){
                 $table_col         = array('选择','序号', '获奖时间', '成果名称', '奖项名称', '颁奖单位', '奖励类别', '奖项级别', '本校排名', '个人排名','完成人','学科门类','业绩（成果）归属年份','奖励届级','奖励等级','是否合作完成','证书号','所属单位','业绩分','奖金','备注','业绩编码');
             }else{
                $table_col         = array('选择','序号', '获奖时间', '成果名称', '奖项名称', '颁奖单位', '奖励等级','奖励类别', '奖项级别', '本校排名', '个人排名','完成人','业绩（成果）归属年份','业绩编码');
             }
       
            $type_name         = ResultsType::Fourth[XPHEnum::Caption];
            return array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }


        // 研究报告、政策建议模块
    public function research_report($param, $is_export,$check){
         if($is_export){
                 $connar['items'] = "db_research_report.id,db_research_report.submit_date,db_research_report.name,db_research_report.type,db_research_report.level,db_research_report.submit_dept,db_research_report.school_rank,db_research_report.personal_rank,author.identity,author.author,db_research_report.words_number,db_research_report.subject,db_research_report.is_cooperation,db_research_report.personal_rank,db_research_report.dept_name,db_research_report.performance_score,db_research_report.bonus,db_research_report.award_year,db_research_report.only_code";
             }else{
                   $connar['items'] = "db_research_report.id,db_research_report.submit_date,db_research_report.name,db_research_report.type,db_research_report.level,db_research_report.submit_dept,db_research_report.school_rank,db_research_report.personal_rank,author.identity,author.author,db_research_report.award_year,db_research_report.only_code";
             }
         
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Fifth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_research_report.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Fifth[XPHEnum::Value].') author1','author1.data_id=db_research_report.id');
                   $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));

                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_research_report.submit_date), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape('  and db_research_report.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Fifth[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Fifth[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_research_report.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Research_report_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['submit_date'] = date('Y-m-d', $v['submit_date']);
                 if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                 if($is_export){
                 $data[$k]['is_cooperation'] = (new CommonWhether())->show($v['is_cooperation']);
                }
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                 $name_arr = explode(",",$param['name']);
                 $name = $name_arr[0];
                  if($name !=$author[$own_identity]){
                        $data[$k]['school_rank']='成员';
                        $data[$k]['personal_rank']='成员';
                    } 
                unset($data[$k]['identity']);             
            }
            if($is_export){
                   $table_col         = array('选择','序号', '批示或采纳时间', '报告名称', '报告类型', '报告级别', '提交单位', '本校排名', '个人排名','作者','字数（万字)','学科门类','是否合作完成','所属单位','业绩分','奖金','业绩（成果）归属年份','业绩编码');
             }else{
                   $table_col         = array('选择','序号', '批示或采纳时间', '报告名称', '报告类型', '报告级别', '提交单位', '本校排名', '个人排名','作者','业绩（成果）归属年份','业绩编码');
             }
         
            $type_name         = ResultsType::Fifth[XPHEnum::Caption];
            return array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);

    }


        // 技术标准模块
    public function technical_standard($param, $is_export,$check){
         if($is_export){
                  $connar['items'] = "db_technical_standard.id,db_technical_standard.publish_time,db_technical_standard.name,db_technical_standard.code,db_technical_standard.publish_dept,db_technical_standard.standard_level,db_technical_standard.school_rank,db_technical_standard.personal_rank,author.identity,author.author,db_technical_standard.dept_name,db_technical_standard.performance_score,db_technical_standard.bonus,db_technical_standard.award_year,db_technical_standard.only_code";
             }else{
                  $connar['items'] = "db_technical_standard.id,db_technical_standard.publish_time,db_technical_standard.name,db_technical_standard.code,db_technical_standard.publish_dept,db_technical_standard.standard_level,db_technical_standard.school_rank,db_technical_standard.personal_rank,author.identity,author.author,db_technical_standard.award_year,db_technical_standard.only_code";
             }
          
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Sixth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_technical_standard.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Sixth[XPHEnum::Value].') author1','author1.data_id=db_technical_standard.id');
                   $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_technical_standard.publish_time), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and db_technical_standard.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Sixth[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Sixth[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_technical_standard.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Technical_standard_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['publish_time'] = date('Y-m-d', $v['publish_time']);
                if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                $name_arr = explode(",",$param['name']);
                 $name = $name_arr[0];
                  if($name !=$author[$own_identity]){
                        $data[$k]['school_rank']='成员';
                        $data[$k]['personal_rank']='成员';
                    } 
                unset($data[$k]['identity']);              
            }
            if($is_export){
                 $table_col         = array('选择','序号', '发布时间', '标准名称', '标准代码', '发布单位', '标准级别', '本校排名', '个人排名','完成人员','所属单位','业绩分','奖金','业绩（成果）归属年份','业绩编码');
             }else{
                     $table_col  = array('选择','序号', '发布时间', '标准名称', '标准代码', '发布单位', '标准级别', '本校排名', '个人排名','完成人员','业绩（成果）归属年份','业绩编码');
             }
       
            $type_name         = ResultsType::Sixth[XPHEnum::Caption];
            return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }


        //纵向课题模块
    public function vertical_project($param, $is_export,$check){
         if($is_export){
                 $connar['items'] = "db_vertical_project.id,db_vertical_project.project_time,db_vertical_project.name,db_vertical_project.source,db_vertical_project.level,db_vertical_project.funding,db_vertical_project.matching_funding,db_vertical_project.school_rank,db_vertical_project.personal_rank,author.identity,author.author,db_vertical_project.is_end,number,db_vertical_project.dept_name,db_vertical_project.performance_score,db_vertical_project.bonus,db_vertical_project.award_year,db_vertical_project.only_code";
             }else{
                   $connar['items'] = "db_vertical_project.id,db_vertical_project.project_time,db_vertical_project.name,db_vertical_project.source,db_vertical_project.level,db_vertical_project.funding,db_vertical_project.matching_funding,db_vertical_project.school_rank,db_vertical_project.personal_rank,author.identity,author.author,db_vertical_project.is_end,db_vertical_project.award_year,db_vertical_project.only_code";
             }
         
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Seventh[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_vertical_project.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Seventh[XPHEnum::Value].') author1','author1.data_id=db_vertical_project.id');
                   $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_vertical_project.project_time), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape('  and db_vertical_project.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Seventh[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Seventh[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_vertical_project.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Vertical_project_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['project_time'] = date('Y-m-d', $v['project_time']);
                 if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                $data[$k]['is_end']=(new CommonWhether)->show($v['is_end']);
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
               $name_arr = explode(",",$param['name']);
                 $name = $name_arr[0];
                  if($name !=$author[$own_identity]){
                        $data[$k]['school_rank']='成员';
                        $data[$k]['personal_rank']='成员';
                    }   
                unset($data[$k]['identity']);         
            }
            $type_name         = ResultsType::Seventh[XPHEnum::Caption];
            if($is_export){
                  $table_col         = array('选择','序号', '立项时间', '课题名称', '来源', '级别', '到校经费', '配套经费', '本校排名', '个人排名',  '完成人','是否结题', '课题编号','所属单位','业绩分','奖金','业绩（成果）归属年份','业绩编码');
             }else{
                  $table_col         = array('选择','序号', '立项时间', '课题名称', '来源', '级别', '到校经费', '配套经费', '本校排名', '个人排名',  '完成人','是否结题','业绩（成果）归属年份','业绩编码');
             }
          
            return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }


        //横向课题模块
    public function horizontal_project($param, $is_export,$check){
          if($is_export){
                   $connar['items'] = "db_horizontal_project.id,db_horizontal_project.project_time,db_horizontal_project.name,db_horizontal_project.source,db_horizontal_project.contract_funding,db_horizontal_project.account_funding,db_horizontal_project.personal_rank,author.identity,author.author,db_horizontal_project.is_end,db_horizontal_project.number,db_horizontal_project.dept_name,db_horizontal_project.performance_score,db_horizontal_project.bonus,db_horizontal_project.award_year,db_horizontal_project.only_code";
             }else{
                   $connar['items'] = "db_horizontal_project.id,db_horizontal_project.project_time,db_horizontal_project.name,db_horizontal_project.source,db_horizontal_project.contract_funding,db_horizontal_project.account_funding,db_horizontal_project.personal_rank,author.identity,author.author,db_horizontal_project.is_end,db_horizontal_project.award_year,db_horizontal_project.only_code";
             }
         
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Eighth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_horizontal_project.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Eighth[XPHEnum::Value].') author1','author1.data_id=db_horizontal_project.id');
                    $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_horizontal_project.project_time), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape('  and db_horizontal_project.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Eighth[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Eighth[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_horizontal_project.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Horizontal_project_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['project_time'] = date('Y-m-d', $v['project_time']);
                 if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                $data[$k]['is_end']=(new CommonWhether)->show($v['is_end']);
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                 if($is_export){
                    $name_arr = explode(",",$param['name']);
                     $name = $name_arr[0];
                      if($name !=$author[$own_identity]){
                            $data[$k]['personal_rank']='成员';
                        }  
                }
                unset($data[$k]['identity']);             
            }
            $type_name         = ResultsType::Eighth[XPHEnum::Caption];
            if($is_export){
                $table_col         = array('选择','序号', '立项时间', '课题名称', '来源', '合同经费', '到校经费', '个人排名','完成人', '是否结题','课题编号','所属单位','业绩分','奖金','业绩（成果）归属年份','业绩编码');
             }else{
                $table_col         = array('选择','序号', '立项时间', '课题名称', '来源', '合同经费', '到校经费', '个人排名','完成人', '是否结题','业绩（成果）归属年份','业绩编码');
             }
            
             return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }   


        //科技转化情况模块2
    public function science_conversion($param, $is_export,$check){
         if($is_export){
                 $connar['items'] = "db_science_conversion.id,db_science_conversion.time,db_science_conversion.name,db_science_conversion.type,db_science_conversion.form,db_science_conversion.science_name,db_science_conversion.contract_funding,db_science_conversion.account_funding,author.author,author.identity,db_science_conversion.personal_rank,db_science_conversion.dept_name,db_science_conversion.performance_score,db_science_conversion.bonus,db_science_conversion.remark,db_science_conversion.award_year,db_science_conversion.only_code";
             }else{
                 $connar['items'] = "db_science_conversion.id,db_science_conversion.time,db_science_conversion.name,db_science_conversion.type,db_science_conversion.form,db_science_conversion.science_name,db_science_conversion.contract_funding,db_science_conversion.account_funding,author.author,author.identity,db_science_conversion.personal_rank,db_science_conversion.award_year,db_science_conversion.only_code";
             }
           
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Ninth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_science_conversion.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Ninth[XPHEnum::Value].') author1','author1.data_id=db_science_conversion.id');
                     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_science_conversion.time), "%Y" ) =?? ', array($param['year']));
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape('  and db_science_conversion.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Ninth[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Ninth[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_science_conversion.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data = $this->CI->Science_conversion_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                $data[$k]['time'] = date('Y-m-d', $v['time']);
                 if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                $name_arr = explode(",",$param['name']);
                 $name = $name_arr[0];
                  if($name !=$author[$own_identity]){
                        $data[$k]['school_rank']='成员';
                        $data[$k]['personal_rank']='成员';
                    }  
                unset($data[$k]['identity']);               
            }
            $type_name         = ResultsType::Ninth[XPHEnum::Caption];
            if($is_export){
                  $table_col         = array('选择','序号', '转化合同签订时间', '转化成果名称', '成果类型', '转化形式', '转化单位', '合同金额', '到账金额','完成人','个人排名','所属单位','业绩分','奖金','备注','业绩（成果）归属年份','业绩编码');
             }else{
                  $table_col         = array('选择','序号', '转化合同签订时间', '转化成果名称', '成果类型', '转化形式', '转化单位', '合同金额', '到账金额','完成人','个人排名','业绩（成果）归属年份','业绩编码');
             }
          
            return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);

    }


        //举办、参加学术交流会、学会年会
    // public function communication($param, $is_export,$check){
    //      if($is_export){
    //                $connar['items'] = "id,time,name,organizer_dept,join_type,type,participants,adress,person_time,paper_num,dept_name,performance_score";
    //          }else{
    //                $connar['items'] = "id,time,name,organizer_dept,join_type,award_year";
    //          }
         
    //         $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value]));
    //         $connar['join']=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Tenth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_communication.id');
    //         if (isset($param['name'])) {
    //             // 没有找到成果人字段
    //             $connar['where'] .= $this->CI->sqlEscape(' and 1<>?? ', array(1));
    //         }
    //         if (isset($param['year']) && $param['year'] != '') {
    //             $connar['where'] .= $this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(time), "%Y" ) =?? ', array($param['year']));
    //         }
    //          if (isset($param['submit_year']) && $param['submit_year'] != '') {
    //             $connar['where'] .= $this->CI->sqlEscape(' and award_year=??  ', array($param['submit_year']));
    //         }  
    //         if($is_export){
    //             if(isset($check)){
    //                 if(in_array(ResultsType::Tenth[XPHEnum::Value], $check)){
    //                     $id_data=$param['check'][ResultsType::Tenth[XPHEnum::Value]];
    //                     foreach ($id_data as $k => $v) {
    //                         if($k==0){
    //                             $id="'".$v."'";
    //                         }else{
    //                             $id.=",'".$v."'";
    //                         }
    //                     }
    //                     $connar['where'] .=" and id in(".$id.")";
    //                 }else{
    //                     $connar['where'].=" and 1<>1";
    //                 }
    //             }else{
    //                 $connar['where'].=" and 1<>1";
    //             }
    //         }
    //         $data = $this->CI->Communication_model->get_list_full($connar);
    //         foreach ($data as $k => $v) {
    //             $data[$k]['time'] = date('Y-m-d', $v['time']);
    //              if(isset($v['award_year'])){
    //                 $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
    //             }else{
    //                  $data[$k]['award_year'] = '';
    //             }
    //         }
    //         $type_name         = ResultsType::Tenth[XPHEnum::Caption];
    //         if($is_export){
    //             $table_col         = array('选择','序号', '参加时间', '活动名称', '主办单位', '参加形式','类别', '参加人','地点','参加人次','提交论文篇数','所属单位','业绩分');
    //          }else{
    //             $table_col         = array('选择','序号', '参加时间', '活动名称', '主办单位', '参加形式','业绩（成果）归属年份');
    //          }
            
    //         return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    // }

    //学术兼职情况模块
    public function academia_job($param, $is_export,$check){
         if($is_export){   
                 $connar['items'] = "db_academia_job.id,db_academia_job.academia_start,db_academia_job.academia_end,db_academia_job.dept,db_academia_job.post,db_academia_job.level,db_academia_job.effect,author.author,db_academia_job.dept_name,db_academia_job.performance_score,db_academia_job.award_year";
             }else{
                 $connar['items'] = "db_academia_job.id,db_academia_job.academia_start,db_academia_job.academia_end,db_academia_job.dept,db_academia_job.post,db_academia_job.level,db_academia_job.effect,db_academia_job.award_year";
             }
           
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Twelfth[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_academia_job.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Twelfth[XPHEnum::Value].') author1','author1.data_id=db_academia_job.id');
                    $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                // $connar['where'].=$this->CI->sqlEscape(' and (DATE_FORMAT(FROM_UNIXTIME(academia_start), "%Y" ) =?? or DATE_FORMAT(FROM_UNIXTIME(academia_start), "%Y" ) =??) ',array($param['year'],$param['year']));
                $connar['where'].=$this->CI->sqlEscape(' and (db_academia_job.academia_start<=?? and  db_academia_job.academia_end>=??)',array(strtotime($param['year']),strtotime($param['year'])));
                // $connar['where'] .= " and 1<>1";
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape('  and db_academia_job.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Twelfth[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Twelfth[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_academia_job.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data               = $this->CI->Academia_job_model->get_list_full($connar);
            foreach ($data as $k => $v) {
                 if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                $data[$k]['academia_start']=date('Y-m-d',$v['academia_start']).'至'.date('Y-m-d',$v['academia_end']);
                unset($data[$k]['academia_end']);
            }
            $type_name          = ResultsType::Twelfth[XPHEnum::Caption];
            if($is_export){

                $table_col          = array('选择','序号', '兼职时间', '兼职机构', '兼职职务', '机构级别', '本校作用','兼职人','所属单位','业绩分' ,'业绩（成果）归属年份');
             }else{
                $table_col          = array('选择','序号', '兼职时间', '兼职机构', '兼职职务', '机构级别', '本校作用','业绩（成果）归属年份');
             }
            
             return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }

        //学科平台模块
    public function subject_platform($param, $is_export,$check){
         if($is_export){
                  $connar['items'] = "db_subject_platform.id,db_subject_platform.receive_time,db_subject_platform.name,db_subject_platform.platform_level,db_subject_platform.platform_type,author.author,author.identity,db_subject_platform.school_rank,db_subject_platform.dept_name,db_subject_platform.cooperation_name,db_subject_platform.funding,db_subject_platform.performance_score,db_subject_platform.bonus,db_subject_platform.award_year,db_subject_platform.only_code";
             }else{
                  $connar['items'] = "db_subject_platform.id,db_subject_platform.receive_time,db_subject_platform.name,db_subject_platform.platform_level,db_subject_platform.platform_type,author.author,author.identity,db_subject_platform.school_rank,db_subject_platform.dept_name,db_subject_platform.cooperation_name,db_subject_platform.funding,db_subject_platform.award_year,db_subject_platform.only_code";
             }
          
            $connar['where'] = $this->CI->sqlEscape("is_del=?? and status=?? and is_submit_cg=??", array(CommonWhether::Not[XPHEnum::Value], ResultState::Publiced[XPHEnum::Value],CommonWhether::Whether[XPHEnum::Value]));
            $connar['join'][0]=array('(select group_concat(db_author.author_name  ORDER BY id ASC) author,group_concat(db_author.identity  ORDER BY id ASC) identity,data_id FROM db_author WHERE db_author.type = '.ResultsType::Thirteen[XPHEnum::Value].'  GROUP BY db_author.data_id ) author','author.data_id=db_subject_platform.id');
            // if (isset($param['name'])) {
            //     $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author.author) ', array($param['name']));
            // }
              if (isset($param['name']) && $param['name']!=-1) {
                    $name_arr = explode(",",$param['name']);
                    $name = $name_arr[0];
                    $identity = $name_arr[1];
                    $connar['join'][1]=array('(select * from db_author where db_author.type='.ResultsType::Thirteen[XPHEnum::Value].') author1','author1.data_id=db_subject_platform.id');
                    $connar['where'] .= $this->CI->sqlEscape(' and find_in_set(??,author1.author_name) and find_in_set(??,author1.identity) ', array($name,$identity));
                }
            if (isset($param['year']) && $param['year'] != '') {
                 $connar['where'].=$this->CI->sqlEscape(' and DATE_FORMAT(FROM_UNIXTIME(db_subject_platform.receive_time), "%Y" ) =?? ',array($param['year']));           
            }
             if (isset($param['submit_year']) && $param['submit_year'] != '') {
                $connar['where'] .= $this->CI->sqlEscape('  and db_subject_platform.award_year=??  ', array($param['submit_year']));
            }  
            if($is_export){
                if(isset($check)){
                    if(in_array(ResultsType::Thirteen[XPHEnum::Value], $check)){
                        $id_data=$param['check'][ResultsType::Thirteen[XPHEnum::Value]];
                        $id = '';
                        foreach ($id_data as $k => $v) {
                            if($k==0){
                                $id="'".$v."'";
                            }else{
                                $id.=",'".$v."'";
                            }
                        }
                        $connar['where'] .=" and db_subject_platform.id in(".$id.")";
                    }else{
                        $connar['where'].=" and 1<>1";
                    }
                }else{
                    $connar['where'].=" and 1<>1";
                }
            }
            $data               = $this->CI->Subject_platform_model->get_list_full($connar);
            $type_name          = ResultsType::Thirteen[XPHEnum::Caption];
            foreach ($data as $k => $v) {          
                $data[$k]['receive_time'] = date('Y-m-d', $v['receive_time']);
                 if(isset($v['award_year'])){
                    $data[$k]['award_year'] = $v['award_year']?$v['award_year']:'';            
                }else{
                     $data[$k]['award_year'] = '';
                }
                // 判断是否外校
                $author=array_unique(explode(',', $v['author']));
                $own_identity=array_search(CommonIdentity::Teacher[XPHEnum::Value], explode(',', $v['identity']));
                $own_author=array_search($param['name'], explode(',', $v['author']));
                // 如果该成果人不是排在成果人第一位，则排名都显示为成员
                $name_arr = explode(",",$param['name']);
                 $name = $name_arr[0];
                  if($name !=$author[$own_identity]){
                        $data[$k]['school_rank']='成员';
                    } 
                unset($data[$k]['identity']);
            }

         
            if($is_export){
                  $table_col          = array('选择','序号','获得时间', '平台名称', '平台级别', '平台类别', '负责人', '学校排名','所属单位','合作单位','到校经费(万元)','业绩分','奖金','业绩（成果）归属年份','业绩编码');
             }else{
                  $table_col          = array('选择','序号','获得时间','平台名称', '平台级别', '平台类别', '负责人', '学校排名','所属单位','合作单位','到校经费(万元)','业绩（成果）归属年份','业绩编码');
             }
          
             return  array('table_name' => $type_name, 'table_col' => $table_col, 'data' => $data);
    }


    
    

}